package com.formaplus.appcom14.db;

import com.formaplus.appcom14.utilitiares.Stat;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SqliteCreator extends SQLiteOpenHelper{

	public SqliteCreator(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {

		String CMD="CREATE TABLE "+Stat.TABLE_NAME+" ("+Stat.COL_ID+" INTEGER PRIMARY KEY autoincrement,"+Stat.COL_Name+" VARCHAR(20)" +
				","+Stat.COL_Add+" VARCHAR(100),"+Stat.COL_Latitude+" DOUBLE,"+Stat.COL_Longitude+" DOUBLE,"+Stat.COL_Phone+" VARCHAR(20),"+Stat.COL_FAV+" INTEGER);";
		db.execSQL(CMD);	
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
		db.execSQL("DROP TABLE "+Stat.TABLE_NAME);
		onCreate(db);
		
	}

}
